﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

namespace He.Web.manage.job
{
    public partial class resume_list : He.Web.UI.Manage
    {
        protected int pageSize = 12;
        protected int page;
        protected int pcount;
        protected string keywords;
        protected void Page_Load(object sender, EventArgs e)
        {
            page = GetInt("page", 0);
            keywords = GetString("keywords");
            if (!IsPostBack)
            {
                chkLoginLevel("viewresume");
                RptBind();
            }
        }

        #region 数据绑定
        private void RptBind()
        {
            this.txtKeywords.Text = this.keywords;
            BLL.resume bll = new BLL.resume();
            string strWhere = Comb_SqlTxt(this.keywords);
            rptInfo.DataSource = bll.GetPageList(pageSize, page, strWhere, "id desc");
            rptInfo.DataBind();
            pcount = bll.GetRecordCount(strWhere);
        }
        #endregion

        #region 组合SQL语句
        protected string Comb_SqlTxt(string _keywords)
        {
            StringBuilder strTemp = new StringBuilder();
            _keywords = _keywords.Replace("'", "");
            strTemp.Append("id>0");
            if (!string.IsNullOrEmpty(_keywords))
            {
                strTemp.Append(" and job_title like '%" + _keywords + "%'");
            }
            return strTemp.ToString();
        }
        #endregion

        //删除
        protected void lbtnDel_Click(object sender, EventArgs e)
        {
            chkLoginLevel("delresume");
            BLL.resume bll = new BLL.resume();
            for (int i = 0; i < rptInfo.Items.Count; i++)
            {
                CheckBox cb = (CheckBox)rptInfo.Items[i].FindControl("Check");
                int id = int.Parse(((HiddenField)rptInfo.Items[i].FindControl("HiddenId")).Value);
                if (cb.Checked)
                {
                    Model.resume model = bll.GetModel(id);
                    bll.Delete(id);
                }
            }
            SaveLogs("[简历管理]批量删除");
            JscriptPrint("批量删除成功啦！", Request.RawUrl, "Success");
        }
        //查询
        protected void btnSelect_Click(object sender, EventArgs e)
        {
            Response.Redirect("resume_list.aspx?" + CombUrlTxt(txtKeywords.Text.Trim()) + "page=0");
        }
    }
}
